<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>添加和移除列表选项</title>
</head>
<body>
<form action="" name="theForm">
    <label for="the-day">
        <select id="the-day" name="theDay" size="5">
            <option value="0" selected="selected">Monday</option>
            <option value="1">Tuesday</option>
            <option value="2">Wednesday</option>
            <option value="3">Thursday</option>
            <option value="4">Firday</option>
            <option value="5">Saturday</option>
            <option value="6">Sunday</option>
        </select>
    </label>
    <br>
    <input type="button" name="btnRemoveWed" value="Remove Wednesday">
    <input type="button" name="btnAddWed" value="Add Wednesday">
    <br>
</form>
<script>
    var theForm = document.theForm;

    function btnRemoveWebClick() {
        var options = theForm.theDay.options;
        if (options[2].text == 'Wednesday') {
            options[2] = null;
        } else {
            alert('There is no Wednesday');
        }
    }

    function btnAddWebClick() {
        var options = theForm.theDay.options;
        if (options[2].text != 'Wednesday') {
            options[options.length] = new Option();
            for (var i = options.length - 1; i > 2; i--) {
                var currentOption = options[i];
                var previousOption = options[i - 1];
                currentOption.text = previousOption.text;
                currentOption.value = previousOption.value;
            }
            options[2] = new Option('Wednesday', 2);
        } else {
            alert('Do you want to have TWO Webnesdays?');
        }
    }

    theForm.btnRemoveWed.addEventListener('click', btnRemoveWebClick);
    theForm.btnAddWed.addEventListener('click', btnAddWebClick);
</script>
</body>
</html>